<template>
  <div style="width: 60%; margin: 0 auto">
    <!-- 标题区域 -->
    <el-card style="margin-bottom: 30px">
      <div>{{ expeObject.name }}</div>
    </el-card>
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="内容" name="first">
        <ExprContent v-bind:message="expeObject"></ExprContent>
      </el-tab-pane>
      <el-tab-pane label="数据集" name="second"
        ><ExprData v-bind:message="id"></ExprData
      ></el-tab-pane>
      <el-tab-pane label="记录" name="third"
        ><ExprRecord v-bind:message="id"></ExprRecord
      ></el-tab-pane>
      <el-tab-pane label="评论" name="fourth"
        ><ExprComment></ExprComment
      ></el-tab-pane>
    </el-tabs>
    <!-- 代码输入区域 -->
    <div style="margin-top: 20px;">
      <el-button type="success">运行</el-button>
      <el-input
        type="textarea"
        :autosize="{ minRows: 4, maxRows: 8 }"
        placeholder="请输入代码"
        v-model="code"
      >
      </el-input>
    </div>
  </div>
</template>

<script>
import ExprContent from "./ExprContent.vue";
import ExprData from "./ExprData.vue";
import ExprRecord from "./ExprRecord.vue";
import ExprComment from "./ExprComment.vue";
export default {
  data() {
    return {
      expeObject: {},
      id: "1",
      activeName: "first",
      code: ""
    };
  },
  components: {
    ExprContent,
    ExprData,
    ExprRecord,
    ExprComment,
  },
  methods: {
    // 切换tab
    handleClick(tab, event) {
      // 发送对应的id
    },
  },
  watch: {
    id(newValue, oldValue) {
      this.$http({
        url: "experiment/" + newValue,
        method: "get",
      })
        .then((response) => {
          if (response.data.code == 0) {
            this.expeObject = response.data.data;
          }
        })
        .catch((err) => err);
    },
  },
  mounted() {
    this.id = this.$route.query.id;
  },
};
</script>

<style>
</style>